﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnTheWay.Domain
{
    public class DomainBase<T, TIService>
    {
        protected Type _tType;
        protected Type _tIServiceType;//服务
        protected string _tName;

        protected bool _isDebug { get { return DataService<TIService>.IsDebug; } }

        public DomainBase()
        {
            _tType = typeof(T);
            _tIServiceType = typeof(TIService);
            _tName = _tType.Name;
        }

        /// <summary>
        /// 执行自定义方法
        /// </summary>
        /// <param name="MothedName">方法名</param>
        /// <param name="parameters">方法参数</param>
        /// <param name="isAbsolutely">是否使用绝对 方法名</param>
        /// <returns></returns>
        public object Invoke(string MothedName, object[] parameters, bool isAbsolutely = false)
        {
            string name = MothedName;
            if (!isAbsolutely)
            {
                name = _tName + MothedName;
            }
            return _tIServiceType.GetMethod(name).Invoke(DataService<TIService>.Service, parameters);
        }

    }
}
